Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:accept CurrentPlayheadPosition with 0 value #638

Merged

Conversation

mmustafa-tse
Copy link
Contributor

Summary

  • A customer reported that when sending a Media Session Start event, the playhead_position will be set to '0' if the user is starting the media session from the beginning of the content which is needed for them since playhead_position marked as a required attribute because they deem it to be integral for all media events, after further investigation it seems that the playhead_position was being dropped due to how JS treats 0 as a false value in a conditional

Testing Plan

  • [Y] Was this tested locally? If not, explain why.
  • I was able to override the my higgs sample app and change the bundle.js code with the one in this PR and tested both cases where we include a playhead_position and when not.

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@mmustafa-tse
Copy link
Contributor Author

mmustafa-tse commented Sep 5, 2024

@rmi22186 @alexs-mparticle - this needs more work as it seems my fix affected the logPlayheadPosition function indirectly as well as in the process of doing so found another bug on the same function without my fix implemented

Edit: this has been updated and now everything working as expected

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. The only issue being the failing tests when it's not node v14. There's got to be an issue with the dependencies, but I don't have time to sort that out right now. I can look more next week.

src/session.ts Outdated
Comment on lines 163 to 165
if (options?.currentPlayheadPosition !== undefined) {
this.currentPlayheadPosition = options?.currentPlayheadPosition;
}
Copy link
Member

@rmi22186 rmi22186 Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since this is TS, i think you can do ?? instead of ||.
https://stackoverflow.com/questions/61480993/when-should-i-use-nullish-coalescing-vs-logical-or

Try that and see if your tests pass. Yay ts!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmi22186 - tested the suggested change and confirmed its working and pushed the new code, thanks!

@rmi22186 rmi22186 merged commit 4b22668 into mParticle:master Sep 16, 2024
5 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants